﻿using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using Pronghorn.Core;
using Pronghorn.Web.Controllers;

namespace Pronghorn.Web
{
	// Note: For instructions on enabling IIS6 or IIS7 classic mode, 
	// visit http://go.microsoft.com/?LinkId=9394801
	public class MvcApplication : ProngHornApplication
	{
		protected void Application_Start()
		{
			RegisterRoutes(RouteTable.Routes);
			RegisterControllerFactory();
		}

		public void RegisterControllerFactory()
		{
			var container = GetContainer();
			container.AddComponent<HomeController>("Pronghorn.Web.Controllers.HomeController");
			var factory = new ProngHornControllerFactory(container);
			ControllerBuilder.Current.SetControllerFactory(factory);
		}

		public static void RegisterRoutes(RouteCollection routes)
		{
			RouteRegistration(routes);
			
			routes.MapRoute(
			    "Default",                                              // Route name
			    "{controller}/{action}/{id}",                           // URL with parameters
			    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
			);
		}
	}
}